package com.deep.stream.amqp.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 交换机等队列间的绑定关系
 *
 * @author deeprado
 */
@Configuration
public class SampleExchangeRelConfig {
    public static final String EXCHANGE = "sample.exchange";
    public static final String QUEUE = "sample.queue";
    public static final String ROUTING_KEY = "sample.routing_key";

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(EXCHANGE);
    }

    @Bean
    public Queue queue() {
        return new Queue(QUEUE);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(directExchange()).with(ROUTING_KEY);
    }

}
